<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <div class="section">
                <h1>Consultar Situação do Empreendimento</h1>
                <h:form id="searchSale">
                    <p:growl id="msg" autoUpdate="true" life="3000"/>
                    <div class="container_24 clearfix">
                        <p:panel styleClass="grid_24" header="Filtros">
                            <p:outputLabel value="Empreendimento:" styleClass="grid_4" />
                            <p:autoComplete required="true" requiredMessage="O Campo Emprendimento é Obrigatório" alt="Empreedimento" label="Empreendimento"
                                            styleClass="grid_18" value="#{managerSituationEnterprise.enterprise}" 
                                            id="enterpriseAutocomplete" completeMethod="#{managerSituationEnterprise.autocompleteEnterprise}"  
                                            var="p" dropdown="true" itemLabel="#{p.name}" itemValue="#{p}" converter="#{autocompleteconverter}" forceSelection="true">
                                <p:ajax event="itemSelect" update="blockAutocomplete, lotAutocomplete"  />
                            </p:autoComplete>

                            <p:outputLabel value="Quadra:" styleClass="grid_4" />
                            <div class="grid_6">
                                <p:selectOneMenu id="blockAutocomplete" value="#{managerSituationEnterprise.block}" >  
                                    <f:selectItem itemLabel="" itemValue="" />  
                                    <f:selectItems value="#{managerSituationEnterprise.selectTypeBlock()}" /> 
                                    <p:ajax update="lotAutocomplete" listener="#{managerSituationEnterprise.lotsByEnterpriseAndBlock()}" />
                                </p:selectOneMenu> 
                            </div>

                            <p:outputLabel value="Lote:" styleClass="grid_4" />
                            <div class="grid_8">
                                <p:selectOneMenu  id="lotAutocomplete" value="#{managerSituationEnterprise.lot.id}" >  
                                    <f:selectItem itemLabel="" itemValue="" />  
                                    <f:selectItems value="#{managerSituationEnterprise.lotsByEnterpriseAndBlock()}" /> 
                                </p:selectOneMenu> 
                            </div>
                            <p:outputLabel value="Situação:" styleClass="grid_4" />
                            <div class="grid_6">
                                <p:selectOneMenu var="s"  value="#{managerSituationEnterprise.status}" >  
                                                                       <f:selectItem itemLabel="" itemValue="" />  

                                    <f:selectItems var="situ" itemLabel="#{situ.name}" itemValue="#{situ}"
                                                   value="#{managerSituationEnterprise.selectStatus()}"/>

                                    <p:column styleClass="#{s.style}" 
                                              style="width:20%;text-align:center;"> 
                                        <div class="#{s.style}" style="width:30px;text-align:center;">
                                            
                                        </div>
                                    </p:column>  

                                    <p:column style="width:80%">  
                                        #{s.name} 
                                    </p:column>
                                </p:selectOneMenu>
                            </div>
                        </p:panel>

                    </div>
                    <div class="buttonAction">
                        <p:commandButton value="Pesquisar" update="tableLots" process="@form" 
                                         icon="ui-icon-search"
                                         actionListener="#{managerSituationEnterprise.search()}" />
                        <p:button value="Voltar"
                                  href="indexsale.xhtml"
                                  icon="ui-icon-arrowreturnthick-1-w"/>

                    </div>
                    <div class="container_24">
                        <p:dataTable id="tableLots"  styleClass="grid_24 tableSituation"
                                     var="lotsValue"
                                     rowIndexVar="idLots"
                                     emptyMessage="Nenhum registro" paginator="true" paginatorPosition="bottom"
                                     rows="10"
                                     value="#{managerSituationEnterprise.lots}">  
                            <f:facet name="header">
                                Lotes
                            </f:facet>
                            <p:column style="width:16px">  
                                <p:rowToggler />  
                            </p:column>
                            <p:column headerText="Status" 
                                      styleClass="#{lotsValue.status.style}"> 
                                <h:outputLabel value="#{lotsValue.status.name}"/>
                            </p:column>  
                            <p:column headerText="Nº"> 
                                <h:outputLabel value="#{lotsValue.num}"/>
                            </p:column>  
                            <p:column headerText="Quadra"> 
                                <h:outputLabel value="#{lotsValue.block}"/>
                            </p:column>  
                            <p:column headerText="Dimensão"> 
                                <h:outputLabel value="#{lotsValue.dimessionX eq null ? 'Variável':lotsValue.dimessionX}"/>
                                <h:outputLabel value="#{lotsValue.dimessionX ne null ? ' X ':''}"/>
                                <h:outputLabel value="#{lotsValue.dimessionY eq null ? '':lotsValue.dimessionY}"/>
                            </p:column>  
                            <p:column headerText="Área"> 
                                <h:outputLabel value="#{lotsValue.area}">
                                    <f:convertNumber pattern="#,###,##0.00"/>
                                </h:outputLabel>
                            </p:column>  
                            <p:column headerText="Tipo"> 
                                <h:outputLabel value="#{lotsValue.typeLot.name}"/>
                            </p:column>  
                            <p:column headerText="m²"> 
                                <h:outputLabel value="#{lotsValue.typeLot.value}">
                                    <f:convertNumber pattern="#,###,##0.00"/>
                                </h:outputLabel>
                            </p:column>  
                            <p:column headerText="A Vista"> 
                                <h:outputLabel value="R$"/>
                                <h:outputLabel value="#{lotsValue.sees}">
                                    <f:convertNumber pattern="#,###,##0.00"/>
                                </h:outputLabel>
                            </p:column>
                            <p:rowExpansion>
                                <p:panel header="Pagamento Parcelado" styleClass="clearfix grid_24">
                                    <p:outputLabel value="A vista:" styleClass="grid_3" />
                                    <h:outputLabel value="R$" styleClass="grid_1"/>
                                    <h:outputLabel value="#{lotsValue.sees}" styleClass="grid_5">
                                        <f:convertNumber pattern="#,###,##0.00"/>
                                    </h:outputLabel>

                                    <p:outputLabel value="Entrada: " styleClass="grid_4" />
                                    <h:outputLabel value="R$" styleClass="grid_1"/>
                                    <h:outputLabel value="#{lotsValue.valueBegin}" styleClass="grid_5">
                                        <f:convertNumber pattern="#,###,##0.00"/>
                                    </h:outputLabel>
                                    <p:dataTable   styleClass="grid_24"
                                                   var="subInterestValue"
                                                   rowIndexVar="idInterest"
                                                   emptyMessage="Nenhum registro"
                                                   value="#{lotsValue.valueInterestParcels}">  
                                        <p:column headerText="Quantidade de Parcelas"> 
                                            <h:outputLabel value="#{subInterestValue.interestParcel.qtd}"/>
                                        </p:column>  
                                        <p:column headerText="Valor">  
                                            <h:outputLabel value="R$ #{subInterestValue.value}">
                                                <f:convertNumber pattern="#,###,##0.00"/>
                                            </h:outputLabel>
                                        </p:column> 
                                    </p:dataTable> 
                                </p:panel>
                            </p:rowExpansion>
                        </p:dataTable> 
                    </div>
                </h:form>
            </div>
        </ui:define>
    </ui:composition>

</html>
